//app.js
App({
  globalData: {
    OPENID:'',
    userInfo: null,
    city: "深圳",
    expert: "",
    islogin: false,
    url: "https://app1.sztravel.com.cn/",
    // imgUrl:"httpss://www.ai-peer.com/file/weixinapp/img/",//所有图片存在文件夹绝对地址
    systemInfo:"",
    headers:{//统一头部信息
      "Content-Type":"application/x-www-form-urlencoded",
      "Device-Id":"",
      "Os":"",
      "Screen":"",
      "User-Token": ""
    },
    defaultheader: {//模拟统一头部信息
      "Content-Type": "application/x-www-form-urlencoded",
      "Device-Id": "",
      "Os": "",
      "Screen": "",
      "User-Token": "c06b550dc4088ed54fcfbc6c3069df34"
    },
    loginheader: {//注册 登录等必须没有"User-Token"的接口headers
      "Content-Type": "application/x-www-form-urlencoded",
      "Device-Id": "",
      "Os": "",
      "Screen": ""
    },
    wxMes:{
      appId: "wxe6c5c76b153676ee",//小程序appid
      secret: "f23366577a9fe17c2a184fb4a06dc980"//小程序secretId
    }
  },
  getUserInfo: function (cb) {
    var that = this
    if (this.globalData.userInfo) {
      typeof cb == "function" && cb(this.globalData.userInfo)
    } else {
      //调用登录接口
      // wx.login({
      //   success: function () {
      //     wx.getUserInfo({
      //       success: function (res) {
      //         console.log(res)
      //         that.globalData.userInfo = res.userInfo
      //         typeof cb == "function" && cb(that.globalData.userInfo)
      //       }
      //     })
      //   }
      // })
    }
  },
  onLaunch: function () {
    var that = this;
    //调用API从本地缓存中获取数据
    // var logs = wx.getStorageSync('logs') || [];
    // logs.unshift(Date.now());
    // wx.setStorageSync('logs', logs);
    //定义接口变量
    wx.getSystemInfo({//配置头部设备信息 
      success:function(res){   
       that.globalData.systemInfo=res;
       that.globalData.headers.Screen = res.screenWidth + "*" + res.screenHeight;
       that.globalData.headers.Os = res.platform == "devtools" ? "ios" : res.platform;
      }
    }); 
    console.log(that.globalData);

  

  },
 
  
  
})